package com.atguigu.system.service;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;

import com.atguigu.model.base.OssProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author： ekode
 * @Date： 2025/9/26 下午3:01
 * @Describe：
 */
@Service
public class OssService {
/*
    @Autowired

    private OssProperties ossProperties;

    public String uploadFile(MultipartFile file, String filePath) {
        // OSS 上传逻辑
        OSS ossClient = new OSSClientBuilder().build(
                ossProperties.getEndpoint(),
                ossProperties.getAccessKeyId(),
                ossProperties.getAccessKeySecret()
        );

        try {
            // 上传文件
            ossClient.putObject(ossProperties.getBucketName(), filePath, file.getInputStream());
            // 返回访问地址
            return ossProperties.getDomain() + "/" + filePath;
        } catch (Exception e) {
            throw new RuntimeException("文件上传失败", e);
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }

*/
}

